package playing;

import playing.action.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class menu {
    public menu(int id) {
        JFrame frame = new JFrame("主菜单界面");
        frame.setSize(400, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);

        JPanel panel = new JPanel(new GridLayout(7, 1));

        JLabel label = new JLabel("输入以下数字进行以下功能");
        panel.add(label);

        JButton adoptButton = new JButton("领养");
        adoptButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new add(id);
            }
        });
        panel.add(adoptButton);

        JButton interactionButton = new JButton("互动");
        interactionButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new interaction(id);
            }
        });
        panel.add(interactionButton);

        JButton friendsButton = new JButton("好友");
        friendsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new friends(id);
            }
        });
        panel.add(friendsButton);

        JButton releaseButton = new JButton("放生");
        releaseButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
               new delete(id);
            }
        });
        panel.add(releaseButton);

        JButton queryButton = new JButton("查询所有植物");
        queryButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
               new showplants(id);
            }
        });
        panel.add(queryButton);

        JButton exitButton = new JButton("退出游戏");
        exitButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        panel.add(exitButton);

        frame.add(panel);
        frame.setVisible(true);
    }

}
